<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>PHP Global Variables</title>
</head>
<body>
<h1>PHP Global Variables</h1>
<div>
    <h3>PHP $GLOBALS</h3>
    <?php
    $x = 75;
    $y = 25;

    function addition(){
        $GLOBALS['z'] = $GLOBALS['x'] + $GLOBALS['y'];
    }

    addition();
    echo($z);
    ?>
</div>
<div>
    <h3>PHP $_SERVER</h3>
    <?php
    echo($_SERVER['PHP_SELF']);
    echo("<br/>");
    echo($_SERVER['SERVER_NAME']);
    echo("<br/>");
    echo($_SERVER['HTTP_HOST']);
    echo("<br/>");
    echo($_SERVER['HTTP_REFERER']);
    echo("<br/>");
    echo($_SERVER['HTTP_USER_AGENT']);
    echo("<br/>");
    echo($_SERVER['SCRIPT_NAME']);
    echo("<br/>");
    echo($_SERVER['SERVER_ADDR']);
    ?>
</div>
<div>
    <h3>PHP $_REQUEST</h3>
    <form method="post" action="<?php echo($_SERVER['PHP_SELF']);?>">
        Name: <input type="text" name="fname"/>
        <input type="submit"/>
    </form>
    <?php
    $name = $_REQUEST['fname'];
    echo($name);
    ?>
</div>
<div>
    <h3>PHP $_POST</h3>
    <form method="post" action="<?php echo($_SERVER['PHP_SELF']);?>">
        Name: <input type="text" name="fname"/>
        <input type="submit"/>
    </form>
    <?php
    $name = $_POST['fname'];
    echo($name);
    ?>
</div>
<div>
    <h3>PHP $_GET</h3>
    <a href="<?php echo($_SERVER['PHP_SELF']);?>?subject=PHP&web=W3schools.com">Test $GET</a>
    <?php
    echo("Study ".$_GET['subject']." at".$_GET['web']);
    ?>
</div>
</body>
</html>